﻿using EleCho.GoCqHttpSdk;
using Microsoft.Extensions.Logging;
using PluginSdk;

namespace TestPlugin;

public class Test : IPlugin
{
    public string Name => "测试";

    public string Description => "测试动态加载";

    public ICommandBase[] Commands { get; set; } = [];

    public ILoggerFactory LoggerFactory { get; set; }

    public void ConfigLogger(ILoggerFactory loggerFactory)
    {
        LoggerFactory = loggerFactory;
    }

    public void Config()
    {
        Commands = [new TestCommand(LoggerFactory.CreateLogger<TestCommand>())];
    }

    public void ConfigSession(ICqActionSession session)
    {
    }
}

public class TestCommand(ILogger logger) : ITextCommand
{
    public string Match => "^#测试动态加载";

    public string Name => "测试动态加载";

    public string Description => "测试动态加载";

    public Permission Permission => Permission.SameUser;

    private readonly ILogger logger = logger;

    public Task Handler(IMessageStream stream)
    {
        return stream.WriteMessage(new("加载成功！"));
    }
}